package homework;

//用户名异常，非受查异常
class UserNameException extends RuntimeException{
    public UserNameException(String message){
        super(message);
    }
}
//密码异常，受查异常
class CodeException extends Exception{
    public CodeException(String message){
        super(message);
    }
}
public class Homework9_25 {
    private String name = "小七";
    private String code = "7968547";

    public static void main(String[] args) {
        Homework9_25 login = new Homework9_25();
        try{
            login.abnormal("小七","796854");
        }catch(CodeException e){
            e.printStackTrace();
        }
    }
    public void abnormal(String name,String code) throws CodeException {
        if(!this.name.equals(name)){
            throw new UserNameException("用户名错误！");
        }
        if(!this.code.equals(code)){
            throw new CodeException("密码错误！");
        }
    }

}
